A cosmology of datatypes : reusability and dependent types
نویسنده
چکیده
This dissertation defends the idea of a closed dependent type theory whose inductive types are encoded in a universe. Each inductive definition arises by interpreting its description – itself a firstclass citizen in the type theory. Datatype-generic programming thus becomes ordinary programming. This approach is illustrated by several generic programs. We then introduce an elaboration of inductive definitions down to the universe of datatypes. By elaborating an inductive definition – a syntactic artefact – to its code – its type theoretic denotation – we obtain an internalised account of inductive types inside type theory. This is a small step toward bootstrapping, i.e. implementing the inductive fragment in the type theory itself. Building upon this universe of datatypes, ornaments let us treat datatypes as the combination of a structure and a logic: they relate datatypes through their common structure. We set out to rationalise this calculus of structures. We study a categorical model of ornaments, based on Cartesian morphisms of containers. We also illustrate the adequacy of our model by recasting the standard idioms into the categorical mould, and by translating the discovered categorical structures into type theoretic artefacts. Nonetheless, the extreme accuracy of these finely indexed datatypes is a curse for code reuse. Similar functions must be duplicated across similarly structured – but logically incompatible – indexed datatypes. We shall see how code reuse can be achieved by ornamenting functions. We thus capture the relationship between functions such as the addition of natural numbers and the concatenation of lists. We also demonstrate how the implementation of the former informs the implementation of the latter.
منابع مشابه
Generic Programming for Dependent Types Constructing Strictly Positive Families
We begin by revisiting the idea of using a universe of types to write generic programs in a dependently typed setting by constructing a universe for Strictly Positive Types (SPTs). Here we extend this construction to cover dependent types, i.e. Strictly Positive Families (SPFs), thereby fixing a gap left open in previous work. Using the approach presented here we are able to represent all of Ep...
متن کاملWhen Do Datatypes Commute?
Polytypic programs are programs that are parameterised by type constructors (like List), unlike polymorphic programs which are parameterised by types (like Int). In this paper we formulate precisely the polytypic programming problem of \commut-ing" two datatypes. The precise formulation involves a novel notion of higher order polymorphism. We demonstrate via a number of examples the relevance a...
متن کاملTracing ambiguity in GADT type inference
GADTs, short for Generalized Algebraic DataTypes, extend usual algebraic datatypes with a form of dependent typing that has many useful applications, but raises serious issues for type inference. Pattern matching on GADTs introduces type equalities with limited scopes, which are a source of ambiguities that may destroy principal types—and must be resolved by type annotations. By tracing ambigui...
متن کاملRecursion on Nested Datatypes in Dependent Type Theory
Nested datatypes are families of datatypes that are indexed over all types and where the datatype constructors relate different members of the family. This may be used to represent variable binding or to maintain certain invariants through typing. In dependent type theory, a major concern is the termination of all expressible programs, so that types that depend on object terms can still be type...
متن کاملImplementing Extensible Compilers
New extensions to programming languages are constantly being proposed. But implementing these extensions usually turns out to be a very difficult and expensive task, since conventional compilers often lack extensibility and reusability. In this paper we present some fundamental techniques to implement extensible compilers in an object-oriented language. For being able to implement extensible co...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2013